<template>
  <div class="history-main">
    <div class="com-header history-header">
        <button class="back" @click="$router.go(-1)"><i></i></button>
        <span>其他排行榜</span>
        <!-- <button class="clear-all" @click="clearHistory">清除全部</button> -->
    </div>
    <!-- 网页内容区域 -->
    <div class="view-content">
       <div class="wrapper">
            <ul>
                <router-link tag="li" :to="'/novelDetail/'+item.book_id" v-for="(item,index) in dataArray" :key="index">
                    <div class="left"><img :src="item.cover" :alt="item.name"></div>
                    <div class="right">
                        <p class="ellipsis title">{{item.name}}</p>
                        <p class="ellipsis">{{item.author}}</p>
                        <p class="ellipsis">{{item.intro}}</p>
                        <p class="ellipsis">{{item.marknum}}人在追 | {{item.retention}}读者留存</p>
                    </div>
                </router-link>
            </ul>
       </div>
    </div>
  </div>
</template>

<script>
    import {Toast} from 'mint-ui'
    import api from '~/plugins/api.js'
    import axios from 'axios'
    export default {
        head: {
            title: '其它排行榜  - 快眼看书',
            meta: [{
                name: 'description',
                content: '快眼看书专注于玄幻小说搜索,新版快眼看书,提供最全的小说保持最快的更新,方便大家愉快地阅读玄幻小说'
            },{
                name: 'keyWords',
                content: '其它排行榜,快眼看书'
            }]
        },
        data() {
            return {
               
            }
        },
        created() {
            if(!process.server&&!this.dataArray.length){
                this.initData()
            }
        },
        methods: {
            async initData() {
                let {query} = this.$route
                let res = await axios.get(api.otherRanking,{params:query})
                if(res){
                    let data = res.data.data
                    this.dataArray = data
                }
            }
        },
        async asyncData({query}){
            if(process.server){
                let res = await axios.get(api.otherRanking,{params:query})
                if(res){
                    let data = res.data.data
                    return {dataArray: data}
                }
            }else{
                return {dataArray: []}
            }
        }
    }
</script>
